﻿using System;
using System.Collections.Generic;
using Illinois.Core.Interfaces;
using Illinois.Core.Models;
using Illinois.Core.Services;
using Moq;
using NUnit.Framework;

namespace Illinois.Core.Test.Services
{
  [TestFixture]
  public class Test_BurnDownService
  {
    private readonly Mock<IBurnDownRepository> _repository = new Mock<IBurnDownRepository>();
    private BurnDownService _service;
    private const int Id = 101;

    [SetUp]
    public void Init()
    {
      _service = new BurnDownService(_repository.Object);
    }

    [Test]
    public void Test_I_Can_Add_A_BurnDown()
    {
      const string title = "SPRINT 00";
      var start = new DateTime(2012, 10, 1);
      var end = new DateTime(2012, 10, 12);
      const int initialStoryPoints = 30;
      const int projectId = 101;

      var result = _service.Add(title, start, end, initialStoryPoints, projectId);
      Assert.AreEqual(0, result);
    }

    [Test]
    public void Test_I_Can_Delete_A_BurnDown()
    {
      _repository.Setup(e => e.Delete(Id)).Returns(0);
      var result = _service.Delete(Id);
      Assert.AreEqual(0, result);
    }

    [Test]
    public void Test_I_Can_Get_A_BurnDown()
    {
      var burnDown = new BurnDown(string.Empty, DateTime.MinValue, DateTime.MinValue, default(int), default(int));
      _repository.Setup(e => e.GetById(Id)).Returns(burnDown);
      var result = _service.GetById(Id);
      Assert.IsNotNull(result);
    }
  }
}
